package com.example.controller;

import org.springframework.web.bind.annotation.*;

import java.util.Date;


@RestController
public class HelloWorld {

    private String name;

    public HelloWorld() {
        System.out.println("HelloWorld  ...");
    }

    @RequestMapping("/hello/{name}")
    public String hello(@PathVariable("name") String name) {
        return "Hello " + name;
    }

    @RequestMapping("/error")
    public String error() {
        int a = 11 / 0;
        return "11 / 0 = " + a;
    }

    @GetMapping(value = "testAdvice")
    public String testAdvice(@ModelAttribute("user") String user, Date date) throws Exception {
        throw new Exception("模拟测试直接抛出异常");
    }

   public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
